<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%-- 
    JSP Name : da_200_01.jsp
    Description : CSR 소식 목록.
    author Seung Hun
    since 2012. 8. 8.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 8. 8.     Seung Hun     최초 생성
--%>
<%@ include file="/WEB-INF/jsp/co/us/include/declare.jspf" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
<head>
<title>현대자동차 CSR &#124; CSR 소식</title>
<meta name="description" content="현대자동차 CSR의 여러 활동국가에서 전해오는 소식을 알려드리는 CSR소식입니다." />
<meta name="keywords" content="현대자동차 CSR 소식, CSR미주소식, CSR 유럽소식, CSR아시아/태평양 소식, CSR 중동소식, CSR 아프리카 소식" />
<%@ include file="/WEB-INF/jsp/co/us/include/header.jspf" %>
<script type="text/javaScript" language="javascript">
$(document).ready(function() {
    /* form validation check */
    onloadCharCheck();
    
    /* 대륙 List Ajax */
    getContCd();

    $("#srchButn").bind("click", moveSearch);    // 검색
    $("#srchTxt").bind("keydown", eventEnter);    // 엔터키 제어
});

/*  
 * 페이징
 */
function movePage(num) {
    $("#currentPageNo").val(num);
    $("#mainForm").attr('action','/da_200_01.do').submit();
}

/*
 * 검색
 */
function moveSearch() {
    if (!isSchrChk($("#srchTxt").val())) {
        alert("검색어에는 특수문자를 입력할 수 없습니다.");
        $("#srchTxt").focus();
        return false;
    }
    
    $("#currentPageNo").val("1");
    $("#mainForm").attr('action','/da_200_01.do').submit();
}

/*
 * 검색 Text EnterKey 처리
 */
function eventEnter() {
    if (event.key == 13) {
        moveSearch();
    }
}

/*
 * 상세페이지 이동
 */
function moveMdfyPage(idx) {
    $("#blbIdx").val(idx);
    $("#mainForm").attr('action','/da_200_02.do').submit();
}

/*
 * 대륙 코드 리스트
 */
function getContCd() {
    var url = "/CO000014.do";
    
    ajaxSubmit(url, "", callbackContListJson);
}

/*
 * 대륙 코드 리스트 Ajax 결과
 */
function callbackContListJson(jsonData) {
    var evalData = eval(jsonData);
    
    if (evalData.jsonArray.length > 0 || evalData.jsonArray != null) {
        for (var i = 0; i < evalData.jsonArray.length; i++) {
            if (evalData.jsonArray[i].dept2Idx == "${rqInfo.contCd}") {
                $("#contCd").append("<option value=\"" + evalData.jsonArray[i].dept2Idx + "\" selected>" + evalData.jsonArray[i].titl + "</option>");
            } else {
                $("#contCd").append("<option value=\"" + evalData.jsonArray[i].dept2Idx + "\">" + evalData.jsonArray[i].titl + "</option>");
            }
        }
    }
    
    var contCd = "${rqInfo.contCd}";
    if(contCd != null && contCd != ""){
        getNatCd($("#contCd").val());    
    }
    
}

/*
 * 국가코드리스트
 */
function getNatCd(val) {
    var url = "/CO000015.do";
    var param = "dept2Idx=" + val;
    
    ajaxSubmit(url, param, callbackNatListJson);
}

/*
 * 국가코드리스트 Ajax 결과
 */
function callbackNatListJson(jsonData) {
    var evalData = eval(jsonData);
    
    $("#natCd").empty().data('options'); 
    $("#natCd").append("<option value=\"\" selected>국가명</option>");
    if (evalData.jsonArray.length > 0 || evalData.jsonArray != null) {
        for (var i = 0; i < evalData.jsonArray.length; i++) {
            if (evalData.jsonArray[i].dept3Idx == "${rqInfo.natCd}") {
                $("#natCd").append("<option value=\"" + evalData.jsonArray[i].dept3Idx + "\" selected>" + evalData.jsonArray[i].titl + "</option>");
            } else {
                $("#natCd").append("<option value=\"" + evalData.jsonArray[i].dept3Idx + "\">" + evalData.jsonArray[i].titl + "</option>");
            }
        }
    }
}
</script>
</head>
<body>
<div id="wrap">
    <!-- top -->
    <%@ include file="/WEB-INF/jsp/co/us/include/top.jsp" %>
    <!-- top -->

    <!-- container -->
    <div id="container">
        <div id="contentsWrap">
            <div id="contentsArea">
                <div class="headingArea">
                    <div class="location">
                        <a href="#">홈</a>
                        <a href="/da_100_01.do">CSR 자료실</a>
                        <span>CSR 소식</span>
                    </div>
                    <h2>CSR 소식</h2>
                </div>
                <div id="contetns">
                   <form id="mainForm" name="mainForm" method="post">
                        <input type="hidden" id="currentPageNo" name="currentPageNo" value="${paginationInfo.currentPageNo}" />
                        <input type="hidden" id="blbIdx" name="blbIdx" value="" />
                        <input type="hidden" id="delIdx" name="delIdx" value="" />
                    <div class="searchArea">
                        <p class="pageResult">총&nbsp;<span class="totalNum">${paginationInfo.totalRecordCount}</span>건, 현재페이지 <span>${paginationInfo.currentPageNo}/${paginationInfo.totalPageCount}</span></p>
                        <div id="search">
                            <fieldset>
                                <legend class="invisible">검색</legend>
                                <select id="contCd" name="contCd" onchange="getNatCd(this.value);" style="width:100px;">
                                    <option value="">대륙명</option>
                                </select>
                                <select id="natCd" name="natCd">
                                    <option value="">국가명</option>
                                </select>
                                <select id="srchScn" name="srchScn">
                                    <option value="" <c:if test="${rqInfo.srchScn == '' }"><c:out value="selected" /></c:if>>전체</option>
                                    <option value="titl" <c:if test="${rqInfo.srchScn == 'titl' }"><c:out value="selected" /></c:if>>제목</option>
                                    <option value="sbc" <c:if test="${rqInfo.srchScn == 'sbc' }"><c:out value="selected" /></c:if>>내용</option>
                                </select>
                                <input type="text" class="formSearch" id="srchTxt" name="srchTxt" value="${rqInfo.srchTxt }" title="검색어" minbyte="2" maxlength="10" /><input type="image" id="srchButn" name="srchButn" class="btnSearch" src="/img/usr/btn/btn_search_font.gif" alt="검색" title="검색" />
                            </fieldset>
                        </div>
                    </div>
                    <table border="1" class="tableList" summary="CSR 소식의 번호,구분,제목,등록일이 기재 되어있는 표">
                        <colgroup>
                            <col width="8%" />
                            <col width="17%" />
                            <col width="50%" />
                            <col width="15%" />
                        </colgroup>
                        <thead>
                            <tr>
                                <th>번호</th>
                                <th>구분</th>
                                <th>제목</th>
                                <th>등록일</th>
                            </tr>
                        </thead>
                        <tbody>
                        <c:choose>
                            <c:when test="${resultList != null && !empty resultList }">
                                <c:forEach var="result" items="${resultList }" varStatus="status">
                            <tr>
                                <td class="num" >${result.blbNo }</td>
                                <td>${result.contCd }&#124;${result.natCd }</td>
                                <c:if test="${fn:length(result.titl) > 45 }">
                                <td class="dirLeft"><a href="#" onclick="moveMdfyPage('${result.blbIdx }');return false;">${fn:substring(result.titl,0,45) }...</a></td>
                                </c:if>
                                <c:if test="${fn:length(result.titl) <= 45 }">
                                <td class="dirLeft"><a href="#" onclick="moveMdfyPage('${result.blbIdx }');return false;">${result.titl }</a></td>
                                </c:if>
                                <td class="num">${result.rgstDt }</td>
                            </tr>
                                </c:forEach>
                            </c:when>
                            <c:otherwise>
                            <tr>
                                <td colspan="4">검색 결과가 없습니다.</td>
                            </tr>
                            </c:otherwise>
                        </c:choose>
                        </tbody>
                    </table>
                    </form>
                    <div class="pageNate">
                        <able:pagination paginationInfo="${paginationInfo }" type="image" jsFunction="movePage" />
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- /container -->

    <!-- footer -->
    <%@ include file="/WEB-INF/jsp/co/us/include/bottom.jsp" %>
    <!-- /footer -->
</div>
</body>
</html>
